package com.huaxindata.im.model.contact;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.huaxindata.im.constants.ContactConstants;

/**
 * 本地手机的通讯录对象，只有两个属性，名称和电话
 */
public class ContactLocal extends Contact implements Parcelable{

    public ContactLocal() {
    }

    public ContactLocal(String name, String phone) {
        this.nickName = name;
        this.phone = phone;
    }

    protected ContactLocal(Parcel in) {
        nickName = in.readString();
        phone = in.readString();
    }

    public static final Parcelable.Creator<ContactLocal> CREATOR = new Parcelable.Creator<ContactLocal>() {
        @Override
        public ContactLocal createFromParcel(Parcel in) {
            return new ContactLocal(in);
        }

        @Override
        public ContactLocal[] newArray(int size) {
            return new ContactLocal[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(nickName);
        dest.writeString(phone);
    }
    @Override
    public String getDuty() {
        if (TextUtils.isEmpty(duty)) {
            return phone;
        } else {
            return super.getDuty();
        }
    }
    @Override
    public String getCompany() {
        if (TextUtils.isEmpty(company)) {
            return ContactConstants.CH_COMPANY;
        } else {
            return super.getCompany();
        }
    }
}
